public class Solution {
    public int uniquePaths(int m, int n) {
        //在原来的m行n列的基础上增加1行和1列，防止后续i - 1和j - 1越界
        int[][] ret = new int[m + 1][n + 1];

        //初始化
        ret[0][1] = 1;

        //遍历矩阵
        for (int i = 1; i < m + 1; i++) {
            for (int j = 1; j < n + 1; j++) {
                ret[i][j] = ret[i - 1][j] + ret[i][j - 1];
            }
        }
        return ret[m][n];
    }
}
